const Scoket = require("./scoket");
const Auth = require("./auth");

const config = {
  wsUrl: "",
  APPID: "75c080c7",
  APISecret: "N2Q4ZDMxMWQyY2QzZWZlNWIyNDI4Mzcw",
  APIKey: "8f0c9db468e74ee35ce70267cb66ba2d",
  uid: "001",
};

const Xunfei = {
  scoket: null,
  init(ws, message) {
    const auth = new Auth(
      config.APIKey,
      config.APISecret,
      "spark-api.xf-yun.com"
    );
    config.wsUrl = auth.getAuthSignUrl();
    this.scoket = new Scoket(config.wsUrl, config.APPID, ws, message);
  },
  send(message) {
    this.scoket.send(message);
  },
};

module.exports = Xunfei;
